package o;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.os.Build.VERSION;
import android.text.TextUtils;
import com.huawei.appgallery.appcomment.api.CommentReplyActivityProtocol;
import com.huawei.appgallery.appcomment.api.CommentReplyActivityProtocol.Request;
import com.huawei.appgallery.appcomment.impl.bean.UserCommentInfoCardBean;
import com.huawei.appgallery.appcomment.ui.usercomment.UserCommentInfoCard;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import o.bch.a;

public class bec {
    private final byte[] ˊ = new byte[0];
    private Activity ˋ;

    class e implements bdz {
        UserCommentInfoCardBean ˋ;
        final /* synthetic */ bec ॱ;

        public e(bec o_bec, UserCommentInfoCardBean userCommentInfoCardBean) {
            this.ॱ = o_bec;
            this.ˋ = userCommentInfoCardBean;
        }

        public void ˊ() {
            this.ॱ.ˎ(this.ˋ);
        }

        public void ˋ() {
        }
    }

    public bec(Activity activity) {
        this.ˋ = activity;
    }

    public void ॱ(final UserCommentInfoCardBean userCommentInfoCardBean, final UserCommentInfoCard userCommentInfoCard, final boolean z) {
        new bdr(this.ˋ, new bdz(this) {
            final /* synthetic */ bec ˊ;

            public void ˊ() {
                if (z) {
                    this.ˊ.ˎ(userCommentInfoCardBean, userCommentInfoCard);
                } else {
                    this.ˊ.ˏ(userCommentInfoCardBean, userCommentInfoCard);
                }
            }

            public void ˋ() {
            }
        }).ˊ();
    }

    public void ॱ(String str, String str2, String str3, cia o_cia) {
        if (o_cia != null && !TextUtils.isEmpty(str)) {
            for (chz o_chz : o_cia.ʻॱ()) {
                if (o_chz != null && o_chz.ˎ.size() > 0) {
                    for (BaseCardBean baseCardBean : o_chz.ˎ) {
                        if (baseCardBean instanceof UserCommentInfoCardBean) {
                            UserCommentInfoCardBean userCommentInfoCardBean = (UserCommentInfoCardBean) baseCardBean;
                            if (str.equals(userCommentInfoCardBean.ͺˏ())) {
                                userCommentInfoCardBean.ˊ().ˊ(str2);
                                userCommentInfoCardBean.ˊ().ˋ(str3);
                                o_cia.ͺ();
                                break;
                            }
                        }
                    }
                }
            }
        }
    }

    public void ˏ(o.bdm.e eVar, cia o_cia) {
        if (o_cia != null) {
            for (chz o_chz : o_cia.ʻॱ()) {
                if (o_chz != null && o_chz.ˎ.size() > 0) {
                    for (BaseCardBean baseCardBean : o_chz.ˎ) {
                        if (baseCardBean instanceof UserCommentInfoCardBean) {
                            UserCommentInfoCardBean userCommentInfoCardBean = (UserCommentInfoCardBean) baseCardBean;
                            if (userCommentInfoCardBean.ͺˏ().equals(eVar.ˏ()) && userCommentInfoCardBean.ˊ().ॱᐝ().equals(eVar.ॱ())) {
                                if (!userCommentInfoCardBean.ˊ().ʽ()) {
                                    int ॱॱ = userCommentInfoCardBean.ˊ().ॱॱ() + eVar.ˋ();
                                    if (ॱॱ < 0) {
                                        ॱॱ = 0;
                                    }
                                    userCommentInfoCardBean.ˊ().ˎ(ॱॱ);
                                    ॱॱ = userCommentInfoCardBean.ˊ().ˊॱ() + eVar.ʻ();
                                    if (ॱॱ < 0) {
                                        ॱॱ = 0;
                                    }
                                    userCommentInfoCardBean.ˊ().ˊ(ॱॱ);
                                }
                                userCommentInfoCardBean.ˊ().ॱ(true);
                                userCommentInfoCardBean.ˊ().ˋ(eVar.ॱॱ());
                                userCommentInfoCardBean.ˊ().ˏ(eVar.ᐝ());
                                o_cia.ͺ();
                            }
                        }
                    }
                }
            }
        }
    }

    public void ˋ(String str, String str2, cia o_cia) {
        if (o_cia != null) {
            for (chz o_chz : o_cia.ʻॱ()) {
                if (o_chz != null && o_chz.ˎ.size() > 0) {
                    for (BaseCardBean baseCardBean : o_chz.ˎ) {
                        if (baseCardBean instanceof UserCommentInfoCardBean) {
                            UserCommentInfoCardBean userCommentInfoCardBean = (UserCommentInfoCardBean) baseCardBean;
                            if (userCommentInfoCardBean.ͺˏ().equals(str2) && userCommentInfoCardBean.ˊ().ॱᐝ().equals(str)) {
                                userCommentInfoCardBean.ˊ().ॱ(userCommentInfoCardBean.ˊ().ˋॱ() + 1);
                                o_cia.ͺ();
                                break;
                            }
                        }
                    }
                }
            }
        }
    }

    public void ˏ(CardBean cardBean) {
        ॱ((UserCommentInfoCardBean) cardBean);
    }

    public void ˎ(cih o_cih) {
        CardBean ˌ = o_cih.ˌ();
        if (ˌ instanceof UserCommentInfoCardBean) {
            try {
                UserCommentInfoCardBean userCommentInfoCardBean = (UserCommentInfoCardBean) ˌ;
                if (userCommentInfoCardBean.ˏ() == 0) {
                    String str;
                    a aVar = new a();
                    aVar.ˏ(userCommentInfoCardBean.v_());
                    aVar.ˋ(userCommentInfoCardBean.ͺˏ());
                    aVar.ˎ(userCommentInfoCardBean.ॱˌ());
                    aVar.ॱ(userCommentInfoCardBean.ॱـ());
                    aVar.ˊ(userCommentInfoCardBean.ˎˎ());
                    if (userCommentInfoCardBean.ॱـ() != null) {
                        PackageInfo ᐝ = ((cdg) cdb.ॱ(cdg.class)).ᐝ(userCommentInfoCardBean.ॱـ());
                        if (!(ᐝ == null || ᐝ.versionName == null)) {
                            str = ᐝ.versionName;
                            if (str == null || str.equals(userCommentInfoCardBean.ˊ().ॱˊ())) {
                                aVar.ॱॱ(userCommentInfoCardBean.ˊ().ʼ());
                                aVar.ʼ(userCommentInfoCardBean.ˊ().ॱˋ());
                                aVar.ʻ(userCommentInfoCardBean.ˊ().ॱᐝ());
                            }
                            aVar.ˋ(userCommentInfoCardBean.ˎ());
                            aVar.ˎ(ˊ());
                            aVar.ˏ(true);
                            new bco().ॱ(this.ˋ, aVar.ˋ());
                        }
                    }
                    str = null;
                    aVar.ॱॱ(userCommentInfoCardBean.ˊ().ʼ());
                    aVar.ʼ(userCommentInfoCardBean.ˊ().ॱˋ());
                    aVar.ʻ(userCommentInfoCardBean.ˊ().ॱᐝ());
                    aVar.ˋ(userCommentInfoCardBean.ˎ());
                    aVar.ˎ(ˊ());
                    aVar.ˏ(true);
                    new bco().ॱ(this.ˋ, aVar.ˋ());
                }
            } catch (Throwable e) {
                bcb.ˋ.ˊ("CommentFragmentController", "showCommentDialog error", e);
            }
        }
    }

    private int ˊ() {
        return ˋ(-1);
    }

    @TargetApi(21)
    private int ˋ(int i) {
        if (VERSION.SDK_INT >= 21) {
            return this.ˋ.getWindow().getNavigationBarColor();
        }
        return i;
    }

    private void ˎ(UserCommentInfoCardBean userCommentInfoCardBean, UserCommentInfoCard userCommentInfoCard) {
        int i = 1;
        synchronized (this.ˊ) {
            if (userCommentInfoCardBean.ˊ().ˏॱ() == 1) {
                userCommentInfoCardBean.ˊ().ˋ(0);
            } else {
                userCommentInfoCardBean.ˊ().ˋ(1);
                i = 0;
            }
        }
        userCommentInfoCardBean.ˊ().ˎ(userCommentInfoCardBean.ˊ().ॱॱ());
        userCommentInfoCardBean.ˊ().ॱ(false);
        if (userCommentInfoCardBean.ˊ().ॱॱ() != 0) {
            userCommentInfoCard.ʼ().setText(cgy.ˎ((double) userCommentInfoCardBean.ˊ().ॱॱ()));
        }
        cfw.ˎ(new bct(userCommentInfoCardBean.ˊ().ॱᐝ(), cdh.ˎ(this.ˋ), i), new bdn(userCommentInfoCardBean.ͺˏ(), userCommentInfoCardBean.ˊ().ॱᐝ(), this.ˋ, i));
    }

    private void ˏ(UserCommentInfoCardBean userCommentInfoCardBean, UserCommentInfoCard userCommentInfoCard) {
        int i = 1;
        synchronized (this.ˊ) {
            if (userCommentInfoCardBean.ˊ().ͺ() == 1) {
                userCommentInfoCardBean.ˊ().ˏ(0);
            } else {
                userCommentInfoCardBean.ˊ().ˏ(1);
                i = 0;
            }
        }
        userCommentInfoCardBean.ˊ().ˊ(userCommentInfoCardBean.ˊ().ˊॱ());
        userCommentInfoCardBean.ˊ().ॱ(false);
        if (userCommentInfoCardBean.ˊ().ˊॱ() != 0) {
            userCommentInfoCard.ॱॱ().setText(cgy.ˎ((double) userCommentInfoCardBean.ˊ().ˊॱ()));
        }
        cfw.ˎ(new bdg(userCommentInfoCardBean.ˊ().ॱᐝ(), cdh.ˎ(this.ˋ), i), new bdx(userCommentInfoCardBean.ͺˏ(), userCommentInfoCardBean.ˊ().ॱᐝ(), this.ˋ, i));
    }

    private void ॱ(UserCommentInfoCardBean userCommentInfoCardBean) {
        new bdr(this.ˋ, new e(this, userCommentInfoCardBean)).ˎ();
    }

    private void ˎ(UserCommentInfoCardBean userCommentInfoCardBean) {
        cjo commentReplyActivityProtocol = new CommentReplyActivityProtocol();
        Request request = new Request();
        request.ˊ(userCommentInfoCardBean.ˊ().ॱᐝ());
        request.ˏ(userCommentInfoCardBean.ͺˏ());
        request.ˊ(userCommentInfoCardBean.ˊ().ˏॱ());
        request.ˋ(userCommentInfoCardBean.ˊ().ͺ());
        commentReplyActivityProtocol.ˏ(request);
        cjk.ˎ().ˋ(this.ˋ, new cjm("appdetailreply.activity", commentReplyActivityProtocol));
    }
}
